﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.ComponentModel;
using System.Xml.Linq;

namespace Pavilion
{
    public class AnimationNode : NodeBase
    {
        private Animation _animation;
        public Animation Animation
        {
            get { return _animation; }
            set
            {
                if (_animation == value)
                    return;

                if (_animation != null)
                    _animation.Disposed -= new Action<Pavilion.Animation>(Animation_Disposed);

                _animation = value;

                if (_animation != null)
                    _animation.Disposed += new Action<Pavilion.Animation>(Animation_Disposed);
            }
        }

        public AnimationNode(string name) : base() { base.Name = name; }
        public AnimationNode(Animation animation, string name): this(name) { this.Animation = animation; }

        public override void Dispose()
        {
            base.Dispose();
            Animation = null;
        }

        private void Animation_Disposed(Animation animation)
        {
            Animation = null;
        }
    }
}
